$(function () {
	getbaseList();
	//增加回车事件
	$("#baseForm").keydown(function(e){
		 keycode = e.which || e.keyCode;
		 if (keycode==13) {
			 search();
		 } 
	});
});
function search(){
	$("#searchBtn").trigger("click");
}
function getbaseList(init){
	if(init==1)$("#baseForm .pageNum").val(1);	
	JY.Model.loading();
	JY.Ajax.doRequest("baseForm",jypath +'/backstage/workflow/online/myTask/findMyHandlingLC?qType='+qType,null,function(data){
		 $("#baseTable tbody").empty();
	 	 var obj=data.obj;
    	 var list=obj.list;
    	 var results=list.results;
     	 var pageNum=list.pageNum,pageSize=list.pageSize,totalRecord=list.totalRecord;
    	 var html="";
    		 if(results!=null&&results.length>0){
        		 var leng=(pageNum-1)*pageSize;//计算序号
        		 for(var i = 0;i<results.length;i++){
            		 var l=results[i];
            		 html+="<tr>";
            		 html+="<td class='center'><label> <input type='checkbox' name='ids' value='"+l.id+"' class='ace' /> <span class='lbl'></span></label></td>";
            		 if(qType==1){
            			 html+="<td class='left'><button class='btn btn-xs btn-success' onclick='todoTask_check(&apos;"+l.formKey+"&apos;,&apos;"+l.businessKey+"&apos;,&apos;"+l.taskId+"&apos;)' ><i class='icon-pencil align-top bigger-125'></i>办理</button></td>";
            		 }else if(qType==2){
            			 html+="<td class='left'><button class='btn btn-xs btn-success'  onclick='todoTask(&apos;"+l.formKey+"&apos;,&apos;"+l.businessKey+"&apos;,&apos;"+l.processInstanceId+"&apos;)'><i class='icon-pencil align-top bigger-125'></i>查看</button></td>";
            		 }else if(qType==3){
            			 html+="<td class='left'><button class='btn btn-xs btn-success'  onclick='todoTask(&apos;"+l.formKey+"&apos;,&apos;"+l.businessKey+"&apos;,&apos;"+l.processInstanceId+"&apos;)'><i class='icon-pencil align-top bigger-125'></i>查看</button></td>";
            		 }
            		 html+="<td class='center hidden-480'>"+JY.Object.notEmpty(l.roomName)+"</td>";
            		 html+="<td class='center hidden-480'>"+JY.Object.notEmpty(l.customerName)+"</td>";
            		 html+="<td class='center hidden-480'>"+JY.Object.notEmpty(l.customerPhone)+"</td>";
            		 html+="<td class='center'>"+JY.Object.notEmpty(l.processDefinitionName)+"</td>";
            		 html+="<td class='center'>"+JY.Object.notEmpty(l.processDefTaskName)+"</td>";
            		 html+="<td class='center hidden-480'>"+JY.Date.Default(l.startTime)+"</td>";
            		 html+="<td class='center hidden-480'>"+JY.Date.Default(l.endTime)+"</td>";
            		 html+="<td class='left hidden-480'>"+JY.Object.notEmpty(l.startUserName)+"</td>"; 
            		 if(qType==1){
            			 html+="<td class='center hidden-480'>待处理</td>";
            		 }else if(qType==2){
            			 html+="<td class='center hidden-480'>已办理</td>"; 
            		 }else if(qType==3){
            			 html+=""; 
            		 }
                     html+="<td class='left hidden-480'>"+JY.Object.notEmpty(l.auditStatus)+"</td>";

                     html+="</tr>";
            	 } 
        		 $("#baseTable tbody").append(html);
        		 JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"getbaseList");
        	 }else{
        		html+="<tr><td colspan='12' class='center'>没有相关数据</td></tr>";
        		$("#baseTable tbody").append(html);
        		$("#pageing ul").empty();//清空分页
        	 }	 
    	 JY.Model.loadingClose();
	 });
}
function todoTask(formKey,id,procInstId){
	var openUrl=jypath+formKey+"?id="+id+"&processFlag=processHistoryShow&procInstId="+procInstId+"&back=error";
	window.open(openUrl);

}


function todoTask_check(formKey,id,taskId){
	var openUrl=jypath+"/processComponent/index?jumpUrl="+formKey+"&id="+id+"&taskId="+taskId+"&back=error";
	window.open(openUrl);

}



